﻿//  Author:
//       Daniel Großer <olav.daniel.grosser@googlemail.com>
//  
//  Copyright (c) 2012 Copyright (C) 2012 by Daniel Großer. This Code is under GNU LGPL 3.0
// 
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.
// 
//  You should have received a copy of the GNU Lesser General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;

namespace Beauty.Contract
{
    /// <summary>
    /// This class stands for a match in the current input stream of the scanner.
    /// </summary>
    public sealed class MatchResult
    {	
		/// <summary>
		/// Initializes a new instance of the <see cref="Beauty.Contract.MatchResult"/> class.
		/// </summary>
		/// <param name='matchingTerminal'>
		/// The terminal that has been matched.
		/// </param>
		/// <param name='match'>
		/// The value that induced the match.
		/// </param>
		public MatchResult(TerminalAttribute matchingTerminal, string match)
		{
			MatchingTerminal = matchingTerminal;
			MatchedString = match;			
		}
		
        /// <summary>
        /// Get/Set the terminal that has been matched. Null, if no match available.
        /// </summary>
        public TerminalAttribute MatchingTerminal { get; private set; }
		
        /// <summary>
        /// Get the length of the match. This is 0, if no match available.
        /// </summary>
        public int MatchedLength
		{
			get
			{
				return (MatchedString ?? string.Empty).Length;
			}
		}
		
		/// <summary>
		/// Gets the matched string.
		/// </summary>
		/// <value>
		/// The matched string.
		/// </value>
		public string MatchedString { get; private set; }		
    }
}
